package com.ebelter.bodyfatscale.ui.activity;


import android.app.Dialog;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ebelter.bodyfatscale.R;
import com.ebelter.bodyfatscale.ui.view.dialogs.TextTipDialog;
import com.ebelter.bodyfatscale.util.StringUtils;
import com.ebelter.btlibrary.btble.common.Fields;
import com.ebelter.btlibrary.util.SpUtil;

import butterknife.BindView;
import butterknife.OnClick;

public class DeviceManagerActivity extends BaseActivity {


    public static final int REQUEST_CODE=54;
    public static final int RESULT_CLEAR_SUCCESS=55;
    @BindView(R.id.modify_back_bt)
    ImageView back_iv;

    @BindView(R.id.devicemanager_mac_address_tv)
    TextView devicemanager_mac_address_tv;


    @BindView(R.id.modify_done_tv)
    TextView modify_done_tv;


    @Override
    protected int loadLayoutById() {
        return R.layout.devicemaneger_ly;
    }

    @Override
    protected void initViews() {
      //  StatusBarUtil.setDarkStatusIcon(this,true);


    }

    @Override
    protected void initData() {
        String mac=SpUtil.readString(Fields.DEVICE_MAC);
        String name=SpUtil.readString(Fields.DEVICE_Name);
        devicemanager_mac_address_tv.setText(StringUtils.getResStr(R.string.scalename_name)+" ("+mac+")");

    }


    @OnClick({ R.id.modify_back_bt, R.id.modify_done_tv})
    public void btClick(View view){
        switch (view.getId()){
            case R.id.modify_back_bt:
                finish();
                break;
            case R.id.modify_done_tv://绑定提示界面现在绑定按钮
                showTipDialog();
                break;

        }
    }

    private void showTipDialog() {

        TextTipDialog textTipDialog=new TextTipDialog(this, StringUtils.getResStr(R.string.device_management_remove_tip));
        textTipDialog.setListener(new TextTipDialog.ICancelOkBtListener() {
            @Override
            public void cancel(Dialog dialogView) {
                dialogView.cancel();
            }

            @Override
            public void ok(Dialog dialogView) {
                SpUtil.writeString(Fields.DEVICE_MAC,null);
                SpUtil.writeString(Fields.DEVICE_Name,null);
                devicemanager_mac_address_tv.setText("");
                dialogView.cancel();
                setResult(RESULT_CLEAR_SUCCESS);
                finish();//直接退出
            }
        });
        textTipDialog.show();
    }

}
